package com.sky.mapper.common;

import com.github.pagehelper.Page;
import com.sky.aop.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Dish;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);
    @AutoFill(OperationType.INSERT)
    void add(Dish d);

    /**
     * 菜品分页条件查询
     * @param dto
     * @return
     */
    Page<DishVO> page(DishPageQueryDTO dto);

    /**
     * 查看在售商品数量
     * @param ids
     * @param enable
     * @return
     */

    Integer onSaleCount(List<Integer> ids, Integer enable);

    /**
     * 批量删除菜品
     * @param ids
     */
    void delete(List<Integer> ids);

    /**
     * 查询回显
     * @param id
     * @return
     */
    @Select("select * from dish where id =#{id}")
    DishVO getInfo(Integer id);

    /**
     * 修改菜品
     * @param dish
     */
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    /**
     * 分类id查菜品
     * @param categoryId
     * @return
     */
    @Select("select * from dish where category_id =#{categoryId}")
    List<Dish> getBycId(Integer categoryId);


}
